package com.example.controller;

import com.example.Repository.CommentRepository;
import com.example.pojo.Result;
import com.example.pojo.dto.CommentDto;
import com.example.pojo.vo.CommentVo;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author crt
 */
@RestController
@RequestMapping("comment")
public class CommentController {

    @Resource
    private CommentRepository commentRepository;


    @PostMapping("/addComment")
    public Result<String> addComment(@Valid @RequestBody CommentDto commentDto){

        return commentRepository.addComment(commentDto);
    }


    @PostMapping("/commentList")
    public Result<List<CommentVo>> getCommentList(@RequestParam Integer trendsId) {
        return commentRepository.getCommentList(trendsId);
    }


    @DeleteMapping("/deleteComment")
    public Result<String> deleteComment(@RequestParam Integer commentId){
        return commentRepository.deleteComment(commentId);
    }
}
